const { defineConfig } = require('@vue/cli-service')
const path = require('path');

const proxyObj = {}
const targetURL = "http://localhost:21810";
// const targetURL = "http://1.92.143.154:8088";

proxyObj['/api'] = {
  ws: false,
  target: targetURL,
  changeOrigin: true,
  pathRewrite: {
    '^/api': ''
  }
}


function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = defineConfig({
  transpileDependencies: true,

  devServer: {
    host: "localhost",
    port: 8080,
    proxy: proxyObj
  },

  pages: {
    index: {
      entry: "src/main.js",
      title: "知识库系统"
    }
  },

  chainWebpack: config => {
    config.module
      .rule('svg')
      .exclude.add(resolve('src/assets/image/icons'))	//svg文件位置
      .end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/assets/image/icons'))	//svg文件位置
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end()
  },



})
